﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Collections;
using GPCSC.Web;
using NickLee.Web.UI;
using NickLee.Common;

namespace GPCSC.Web.sjsbyes
{
    public partial class FKB : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                //string hdid = Usual.f_querystringToString("hdid");
                //string value = Usual.f_querystringToString("value");
                //if (value == "1")//已提交
                //{
                //    this.trbutton.Style.Add("display","none");
                //    f_fristLoad(hdid);
                //}
                //else if (value == "0") //未提交
                //{
                //    f_fristLoad(hdid);
                //}
                //else//新增
                //{

                //    f_fristLoads();

                //}
                f_fristLoads();
            }
        }
        protected void f_fristLoads()
        {
            //byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
            //Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
            //Model.CL_USER_S users = (Model.CL_USER_S)userInfoTable["SYS_USER"];
            //this.MtxtD_LgName.Value = users.USERNAME.ToString();
            //this.MtxtD_zzMM.Value = users.PD_CompanyName.ToString();
            //this.MtxtD_llgblb.Value = users.DepartName.ToString();
            //this.MtxtD_gzdw.Value = users.POSTName.ToString();
            //this.MtxtD_LGid.Value = users.CL_USER_SOID.ToString();
            //this.hdis.Value = Guid.NewGuid().ToString();
            string hdid = Usual.f_querystringToString("hdid");
            string lgid = Usual.f_querystringToString("userid");
            buildhd(hdid);
            nc(hdid,lgid);
            sq(hdid, lgid);
            qy(hdid, lgid);  

        }
        //绑定活动基本情况
        protected void buildhd( string hdid)
        { 
            Hashtable htable = new Hashtable();
            htable.Add("@hdid",hdid);
          
            DataSet ds = new SqlReadXml().ReaderDataSet("sel_TB_HDQK_byid",htable);
            if(ds.Tables.Count>0)
            {
                base.o_uiTable = UIFactory.UIFactory_Set(this,ds.Tables[0]);
            }
        }
        /// <summary>
        /// 农村
        /// </summary>
        protected void nc(string  hdid, string  lgid)
        {
            Hashtable htable = new Hashtable();
            htable.Add("@hdid", hdid);
            htable.Add("@lgid", lgid);
            DataSet ds = new SqlReadXml().ReaderDataSet("sel_NongCun_byid", htable);
            if (ds.Tables.Count > 0)
            {
                base.o_uiTable = UIFactory.UIFactory_Set(this, ds.Tables[0]);
            }
        }
        /// <summary>
        /// 社区
        /// </summary>
        protected void sq(string hdid, string lgid)
        {
            Hashtable htable = new Hashtable();
            htable.Add("@hdid", hdid);
            htable.Add("@lgid", lgid);
            DataSet ds = new SqlReadXml().ReaderDataSet("sel_SheQu_byid", htable);
            if (ds.Tables.Count > 0)
            {
                base.o_uiTable = UIFactory.UIFactory_Set(this, ds.Tables[0]);
            }
        }
        /// <summary>
        /// 企业
        /// </summary>
        protected void qy(string hdid, string lgid)
        {
            Hashtable htable = new Hashtable();
            htable.Add("@hdid", hdid);
            htable.Add("@lgid", lgid);
            DataSet ds = new SqlReadXml().ReaderDataSet("sel_QiYe_byid", htable);
            if (ds.Tables.Count > 0)
            {
                base.o_uiTable = UIFactory.UIFactory_Set(this, ds.Tables[0]);
            }
        }
        //protected void f_fristLoad(string PrimaryKey)
        //{
          
        //    base.o_uiTable.Clear();
        //    SqlReadXml org = new SqlReadXml();
        //    base.o_uiTable.Add("@HDids", PrimaryKey);
        //    base.m_uiDataSet = org.ReaderDataSet("sel_fklist_byid", base.o_uiTable);
        //    if (m_uiDataSet.Tables.Count > 0)
        //    {
        //        if (m_uiDataSet.Tables[0].Rows.Count > 0)
        //        {
        //            this.hdis.Value = m_uiDataSet.Tables[0].Rows[0]["HDId"].ToString();
        //        }
        //        else
        //        {
        //            this.hdis.Value = Guid.NewGuid().ToString();
        //        }
        //    }
           
        //    //this.hdname.Value = m_uiDataSet.Tables[0].Rows[0]["hdtitile"].ToString();
        //    if (base.m_uiDataSet.Tables.Count > 0)
        //    {
        //        if (base.m_uiDataSet.Tables[0].Rows.Count > 0)
        //        {
        //            //UIFactory set UI controls value:界面工厂设置界面控件值
        //            try
        //            {
        //                base.o_uiTable = UIFactory.UIFactory_Set(this, base.m_uiDataSet.Tables[0]);

        //            }
        //            catch
        //            {

        //            }


        //        }
        //    }
        //    f_fristLoads();
        //}
        //protected void Button1_Click(object sender, EventArgs e)
        //{
        //    savepost("0");//未提交
        //}

        //protected void Button2_Click(object sender, EventArgs e)
        //{
        //    savepost("1");//已提交
        //}
        //protected void savepost(string value)
        //{
        //    try
        //    {
        //        Hashtable htable = f_getElements(base.o_uiTable,value);
        //        string values = Usual.f_querystringToString("value");
        //        SQLServerDAL.databyhtable dtable = new SQLServerDAL.databyhtable();
        //        if (values == "2")
        //        {
        //            dtable.databyhtables(htable, "add", "TB_HDQK", "", "");
        //            this.Response.Write("<script>alert('添加反馈表成功！');window.location.href='myfkLIst.aspx';</script>");
        //        }
        //        else if (values == "0")
        //        {
        //            dtable.databyhtables(htable, "update", "TB_HDQK", "HDId", this.hdis.Value);
        //            this.Response.Write("<script>alert('更新反馈表成功！');window.location.href='myfkLIst.aspx';</script>");
        //        }
        //    }
        //    catch (Exception ee)
        //    {
        //        throw ee;
        //    }


        //}
        //public Hashtable f_getElements(Hashtable o_uiTable,string value)
        //{
        //    //UIFactory Get Values as Hashtable:界面工厂获取值，并保存在哈希表

        //    string values = Usual.f_querystringToString("value");
        //    base.o_uiTable.Clear();
        //    base.o_uiTable = UIFactory.UIFactory_Get(this);
        //    if(values == "2")
        //    {
        //        base.o_uiTable.Add("HDId", this.hdis.Value);
        //    base.o_uiTable.Add("fkistj", value);
        //    base.o_uiTable.Add("HDids", Usual.f_querystringToString("hdid"));
        //    //base.o_uiTable.Add("HDName", Usual.f_querystringToString("hdid"));
        //    }
        //    else
        //    {
        //     base.o_uiTable.Add("HDId", this.hdis.Value);
        //    base.o_uiTable.Add("fkistj", value);
        //    base.o_uiTable.Add("HDids", Usual.f_querystringToString("hdid"));
        //    } 
        //    return base.o_uiTable;
        //}

        //protected void LCallBack_Callback(object sender, CallBackEventArgs e)
        //{
        //    try
        //    {


        //        Hashtable htable = new Hashtable();
        //        htable.Add("hdwt_id", Guid.NewGuid().ToString());
        //        htable.Add("lgid", this.MtxtD_LGid.Value.ToString());
        //        htable.Add("hdid", this.hdis.Value);
        //        htable.Add("wtvalue", e.Parameters[0].ToString());
        //        htable.Add("juvalue", e.Parameters[1].ToString());
        //        htable.Add("wttex", e.Parameters[2].ToString());
        //        htable.Add("jutext", e.Parameters[3].ToString());//
        //        htable.Add("isfor", e.Parameters[4].ToString());
        //        SQLServerDAL.databyhtable dtable = new SQLServerDAL.databyhtable();
        //        dtable.databyhtables(htable, "add", "wts_table", "", "");
        //    }
        //    catch ( Exception ee)
        //    {
        //        throw ee;
        //    }
        //}
    }
}